package com.beta.restapi.controller;

import com.beta.common.web.ContentType;
import com.beta.restapi.internal.Consts;
import com.beta.restapi.internal.annotation.AuthSetting;
import com.beta.entity.VersionInfos;
import com.beta.restapi.internal.annotation.AuthStrategy;
import com.beta.service.IVersionInfosService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by wy on 2016/11/17.
 */
@Api(tags = {Consts.Resource.VERSION})
@RestController
@RequestMapping(Consts.API_PATH_PREFIX)
public class VersionController extends BaseController {

    @Autowired
    private IVersionInfosService versionInfosService;

    @ApiResponses({@ApiResponse(code = 200, message = "success", response = VersionInfos.class)})
    @GetMapping(value = "/latest_version", produces = {ContentType.JSON})
    @AuthSetting(level = AuthStrategy.ANONYMOUS)
    public Object letestVersion() {
        return ok(versionInfosService.getLatestVersionInfo());
    }

}
